﻿using System;
using System.Windows;

namespace C4Tools.ML2
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            string fileName = null;

            for (int i=0; i < e.Args.Length; i++)
            {
                switch (e.Args[i])
                {
                    case "-f":
                        i++;
                        if (e.Args.Length <= i) throw new ArgumentException(e.Args[i-1]);
                        fileName = e.Args[i];
                        break;

                        // can imagine displaying help here
                    default:
                        throw new ArgumentException(e.Args[i]);
                }
            }

            if (fileName != null)
            {
                // build the list and save the file with no UI
                new ListCreator(fileName).Build();
            }
            else
            {
                new MainWindow().ShowDialog();
            }
            this.Shutdown();
        }
    }
}
